package cn.juque.jdfsystem.dispatch;

import cn.juque.jdfsystem.task.*;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author juque
 * @version 1.0.0
 * <ul>
 *     <li>DispatchService</li>
 * </ul>
 * @date 2023-01-11 14:21:21
 **/
@Service("dispatchService")
public class DispatchService {

    @Resource
    private RegisterInfoUpdateTask registerInfoUpdateTask;

    @Resource
    private HeartbeatTask heartbeatTask;

    @Resource
    private ClearHotFileTask clearHotFileTask;

    @Resource
    private CheckFileExistsTask checkFileExistsTask;

    @Resource
    private ClearInValidFileTask clearInValidFileTask;

    @Scheduled(cron = "0/15 * * * * ?")
    public void executeRegisterInfoUpdateTask() {
        this.registerInfoUpdateTask.start(null);
    }

    @Scheduled(cron = "0/5 * * * * ?")
    public void executeHeartbeatTask() {
        this.heartbeatTask.start(null);
    }

    @Scheduled(cron = "0/1 * * * * ?")
    public void executeClearHotFile() {
        this.clearHotFileTask.start(null);
    }

    @Scheduled(cron = "0 0 1 * * ?")
    public void executeCheckFileExists() {
        this.checkFileExistsTask.start(null);
    }

    @Scheduled(cron = "0 0 1 * * ?")
    public void executeClearInvalidFile() {
        this.clearInValidFileTask.start(null);
    }
}
